package net.capstone.cra.smartcontroller.motion;

import java.util.ArrayList;
import java.util.Iterator;

/**
 * The Class MotionDetector.
 */
public class MotionDetector {
	
	/**
	 * The motion event list.
	 */
	private ArrayList<Motion> motionEventList;
	
	/**
	 * Instantiates a new motion detector.
	 */
	public MotionDetector() {
		motionEventList = new ArrayList<Motion>(10);
		motionEventList.add(new ShakeMotion());		// Shake 
	}
	
	/**
	 * Detect.
	 * 
	 * @param event
	 *            the event
	 * @return the int
	 */
	public int detect(AccelerometerEvent event) {
		Iterator<Motion> iter = motionEventList.iterator();
		
		while (iter.hasNext()) {
			Motion m = iter.next();
			
			if (m.detect(event)) {
				return m.getType();
			}
		}
		
		// If not detected
		return Motion.TYPE_NONE;
	}
}
